<?php if ( ! defined('SERVER_ROOT')) exit('No direct script access allowed');
/**
 * MVC Ultra - A ultralight weight MVC framework for PHP
 *
 * MVC ultra is very simple MVC framework that is designed to be easy to use and learn.
 * It does not have all of other frameworks but you add what you need when you need it
 * and understand better whats going on.
 *
 *@author Warren Thomas <wiley_warren@yahoo.com>
 *@copyright Copyright (c) 2012.
 *
 ** 20121027/Warren Thomas      - Created MVC Ultra
 *
 */

/**
 * ultra_config is the primary class for Ultra MVC
 *
 * ultra_config is a singleton class that access to
 * mvc_ultra configuration file
 *
 *@package core
 *
 */

class ultra_config {
    
    /**
     * Holds instance of self to support singleton pattern
     *
     *@access private
     *@property ultra_config $instance
     *
     */
    private static $instance = null;
    
    /**
     * This variable will holds the path of the config file
     *
     * @access private
     * @property string $config_file
     * 
     */
    private static $config_file = CONFIG_FILE;
    
    /**
     * This variable will holds config array structure
     *
     * @access public
     * @property string $config
     * 
     */
    public static $config = array();
    
    /**
     * getInstance() - generates ultra_config object and singleton pattern 
     * 
     * @access public
     * @static
     * @return ultra_mvc retrun instance of ultra_mvc
     * 
     */
    public static function getInstance() 
    {
        // if self not instanciated create instance of self
        if( !( self::$instance instanceof ultra_config) ) {
            self::$instance = new ultra_config();
            self::$config = parse_ini_file ( self::$config_file , true ) ;
        }
        // return self
        return self::$config;
    }

    /**
     * __clone() - disable clone functionality to support singleton pattern
     *
     * @access public
     * @final
     * @return void
     * @exception BadMethodCallException
     */
    public final function __clone()
    {
        throw new BadMethodCallException("Clone is not allowed");
    }
}